package com.seele.tigerwallet.ui.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.seele.tigerwallet.R;
import com.seele.tigerwallet.model.AssetsModel;
import com.seele.tigerwallet.model.UserInfo;
import com.seele.tigerwallet.ui.callback.ItemMoveListener;
import com.seele.tigerwallet.ui.manager.GlideManager;
import com.seele.tigerwallet.ui.utils.DataUtils;
import com.seele.tigerwallet.ui.utils.SPUtils;
import com.seele.tigerwallet.ui.utils.TypefaceUtils;
import com.seele.tigerwallet.ui.views.SwitchView;

import java.util.Collections;

public class AddAssetsAdapter extends BaseQuickAdapter<AssetsModel, BaseViewHolder> {

    public AddAssetsAdapter(int layoutResId) {
        super(layoutResId);
    }
    @Override
    protected void convert(final BaseViewHolder helper, final AssetsModel item) {
        if (!TextUtils.isEmpty(item.symbol)) {
            helper.setText(R.id.token_name_tv, item.symbol);
        }
        if (!TextUtils.isEmpty(item.detail)) {
            helper.setText(R.id.token_detail_name_tv, item.detail);
        }
        if (!TextUtils.isEmpty(item.addr)) {
//            helper.setText(R.id.token_address_tv, item.addr);



            helper.setText(R.id.token_address_tv, DataUtils.getAddr(item.addr));
        }

        ImageView imageView = helper.getView(R.id.token_icon_img);

        RelativeLayout relativeLayout = helper.getView(R.id.add_rv);

        GlideManager.loadUrl(mContext, item.id + "", imageView);
        if (item.candisable==0){
            helper.setVisible(R.id.check_img,false);
            helper.setVisible(R.id.check_ll,false);
            helper.setBackgroundRes(R.id.add_rv,R.drawable.item_normal);
        }else {
            helper.setVisible(R.id.check_img,true);
            helper.setVisible(R.id.check_ll,true);
            helper.setBackgroundRes(R.id.add_rv,R.drawable.item_selector);
            if (item.isOpen){
                helper.setImageResource(R.id.check_img,R.drawable.icon_add_select);
                helper.setBackgroundRes(R.id.add_rv,R.drawable.item_normal);
                helper.setBackgroundRes(R.id.check_ll,R.drawable.item_normal);

            }else {
                helper.setImageResource(R.id.check_img,R.drawable.icon_add_normal);
                helper.setBackgroundRes(R.id.add_rv,R.drawable.item_selector);
                helper.setBackgroundRes(R.id.check_ll,R.drawable.item_selector);
            }
        }

        helper.addOnClickListener(R.id.check_ll);



    }
}
